import 'package:flutter/material.dart';
import 'package:kasax_demos2/appdemo/sbnb/ui_piclist.dart';

class SampleMyBottomNavigationbarWidget extends StatefulWidget {
  const SampleMyBottomNavigationbarWidget({Key? key}) : super(key: key);

  @override
  _SampleMyBottomNavigationbarWidgetState createState() =>
      _SampleMyBottomNavigationbarWidgetState();
}

class _SampleMyBottomNavigationbarWidgetState
    extends State<SampleMyBottomNavigationbarWidget> {
  List<UIHome> homeList = [
    UIHome(0),
    UIHome(1),
  ];

  int currentIndex = 0;

  List<Tab> tabList = [
    Tab(
      icon: Icon(Icons.home),
      text: "",
    ),
    Tab(
      icon: Icon(Icons.topic),
      text: "",
    )
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text("不规则底部导航"),
      ),
      body: homeList[currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: currentIndex,
        onTap: handleOnTabChanged,
        selectedItemColor: Colors.yellow,
        backgroundColor: Colors.lightBlue,
        unselectedItemColor: Colors.white,
        // items: [
        //   BottomNavigationBarItem(icon: Icon(Icons.home), label: ""),
        //   BottomNavigationBarItem(icon: Icon(Icons.border_top), label: ""),
        // ],
        items: tabList
            .map((item) => BottomNavigationBarItem(icon: item.icon!, label: ""))
            .toList(),
      ),
    );
  }

  void handleOnTabChanged(int index) {
    setState(() {
      currentIndex = index;
    });
  }
}
